/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * principal.java
 *
 * Created on 02/02/2010, 16:12:13
 */
/**
 *
 * @author welton
 */
public class principal extends javax.swing.JFrame {

    String pontoCardeal[] = new String[4];
    boolean result;
    Integer sentido;

    /** Creates new form principal */
    public principal() {
        initComponents();
        result = false;
        pontoCardeal[0] = "Norte";
        pontoCardeal[1] = "Leste";
        pontoCardeal[2] = "Sul";
        pontoCardeal[3] = "Oeste";

        btFrente.setEnabled(false);
        btEsquerda.setEnabled(false);
        btDireita.setEnabled(false);




    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        buttonGroup1 = new javax.swing.ButtonGroup();
        btEsquerda = new javax.swing.JButton();
        btDireita = new javax.swing.JButton();
        btFrente = new javax.swing.JButton();
        rdNorte = new javax.swing.JRadioButton();
        rdLeste = new javax.swing.JRadioButton();
        rdSul = new javax.swing.JRadioButton();
        rdOeste = new javax.swing.JRadioButton();
        jLabel1 = new javax.swing.JLabel();
        lbSentido = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("Direcao");

        btEsquerda.setText("Esquerda");
        btEsquerda.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btEsquerdaActionPerformed(evt);
            }
        });

        btDireita.setText("Direita");
        btDireita.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btDireitaActionPerformed(evt);
            }
        });

        btFrente.setText("Em Frente");
        btFrente.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btFrenteActionPerformed(evt);
            }
        });

        buttonGroup1.add(rdNorte);
        rdNorte.setText("Norte");
        rdNorte.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                rdNorteActionPerformed(evt);
            }
        });

        buttonGroup1.add(rdLeste);
        rdLeste.setText("Leste");
        rdLeste.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                rdLesteActionPerformed(evt);
            }
        });

        buttonGroup1.add(rdSul);
        rdSul.setText("Sul");
        rdSul.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                rdSulActionPerformed(evt);
            }
        });

        buttonGroup1.add(rdOeste);
        rdOeste.setText("Oeste");
        rdOeste.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                rdOesteActionPerformed(evt);
            }
        });

        jLabel1.setText("Informe a posição inicial");

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(21, 21, 21)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(rdOeste)
                                .addGap(226, 226, 226)
                                .addComponent(lbSentido, javax.swing.GroupLayout.PREFERRED_SIZE, 191, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addComponent(rdSul)
                            .addGroup(layout.createSequentialGroup()
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(rdNorte)
                                    .addComponent(rdLeste))
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addGroup(layout.createSequentialGroup()
                                        .addGap(148, 148, 148)
                                        .addComponent(btEsquerda)
                                        .addGap(18, 18, 18)
                                        .addComponent(btDireita))
                                    .addGroup(layout.createSequentialGroup()
                                        .addGap(186, 186, 186)
                                        .addComponent(btFrente))))))
                    .addGroup(layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jLabel1)))
                .addContainerGap(31, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jLabel1)
                        .addGap(14, 14, 14)
                        .addComponent(rdNorte))
                    .addComponent(btFrente))
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(rdLeste)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createSequentialGroup()
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(rdSul)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(rdOeste)
                                .addContainerGap(38, Short.MAX_VALUE))
                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(lbSentido, javax.swing.GroupLayout.PREFERRED_SIZE, 24, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addContainerGap())))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(20, 20, 20)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(btEsquerda)
                            .addComponent(btDireita))
                        .addContainerGap())))
        );

        java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
        setBounds((screenSize.width-540)/2, (screenSize.height-215)/2, 540, 215);
    }// </editor-fold>//GEN-END:initComponents

    private void rdNorteActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_rdNorteActionPerformed

        btFrente.setEnabled(true);
        btEsquerda.setEnabled(true);
        btDireita.setEnabled(true);
        rdSul.setEnabled(false);
        rdLeste.setEnabled(false);
        rdOeste.setEnabled(false);

        sentido = 0;

    }//GEN-LAST:event_rdNorteActionPerformed

    private void rdLesteActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_rdLesteActionPerformed
        btFrente.setEnabled(true);
        btEsquerda.setEnabled(true);
        btDireita.setEnabled(true);
        rdNorte.setEnabled(false);
        rdSul.setEnabled(false);
        rdOeste.setEnabled(false);
        sentido = 1;
    }//GEN-LAST:event_rdLesteActionPerformed

    private void rdSulActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_rdSulActionPerformed
        btFrente.setEnabled(true);
        btEsquerda.setEnabled(true);
        btDireita.setEnabled(true);
        rdNorte.setEnabled(false);
        rdLeste.setEnabled(false);
        rdOeste.setEnabled(false);
        sentido = 2;

    }//GEN-LAST:event_rdSulActionPerformed

    private void rdOesteActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_rdOesteActionPerformed
        btFrente.setEnabled(true);
        btEsquerda.setEnabled(true);
        btDireita.setEnabled(true);
        rdNorte.setEnabled(false);
        rdSul.setEnabled(false);
        rdLeste.setEnabled(false);
        sentido = 3;
    }//GEN-LAST:event_rdOesteActionPerformed

    private void btFrenteActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btFrenteActionPerformed
        sentido+= 0;
        mostraDirecao();
        System.out.println(sentido);
    }//GEN-LAST:event_btFrenteActionPerformed

    private void btEsquerdaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btEsquerdaActionPerformed

        sentido+= -1;
        mostraDirecao();
        System.out.println(sentido);
    }//GEN-LAST:event_btEsquerdaActionPerformed

    private void btDireitaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btDireitaActionPerformed
        sentido+=1;
        mostraDirecao();
        System.out.println(sentido);
    }//GEN-LAST:event_btDireitaActionPerformed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                new principal().setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btDireita;
    private javax.swing.JButton btEsquerda;
    private javax.swing.JButton btFrente;
    private javax.swing.ButtonGroup buttonGroup1;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel lbSentido;
    private javax.swing.JRadioButton rdLeste;
    private javax.swing.JRadioButton rdNorte;
    private javax.swing.JRadioButton rdOeste;
    private javax.swing.JRadioButton rdSul;
    // End of variables declaration//GEN-END:variables


public void mostraDirecao(){
    if (sentido == -1){
        sentido = 3;
    }

    if(sentido == 4){
        sentido = 0;
    }

    lbSentido.setText("Vc esta indo para o "+pontoCardeal[sentido]);

}

}

